
import Foundation
import MBProgressHUD
import WCDBSwift


class AppDataStore {
    
    static let share = AppDataStore()
    var currentHud: MBProgressHUD?
    var isConnectDeviceWiFi = false
    var userInfoModel: UserInfoModel?

    var activityIndicator: UIActivityIndicatorView?
    var alert: UIViewController?
    
    private init() {
        
    }

}


final class WalletModuleModel: DatabaseEntity {
    
    var userId: Int = 0
    var walletInfo: String = ""
    var walletDepositUsdt: String = ""
    var swapData: String = ""

    enum CodingKeys: String, CodingTableKey {
        typealias Root = WalletModuleModel
        case userId, walletInfo, walletDepositUsdt, swapData

        static let objectRelationalMapping = TableBinding(CodingKeys.self) {
            BindColumnConstraint(userId, isPrimary: true)
        }
    }
    
    class var current: WalletModuleModel {
        if let walletModuleModel = WalletModuleModel.getObject(where: WalletModuleModel.Properties.userId == UserInfo.userId) {
            return walletModuleModel
        } else {
            let walletModuleModel = WalletModuleModel()
            walletModuleModel.userId = UserInfo.userId
            return walletModuleModel
        }
    }
    
}

 
final class MineModuleModel: DatabaseEntity {
    
    var userId: Int = 0
    var matrixData: String = ""
    var referralNetworkData: String = ""

    enum CodingKeys: String, CodingTableKey {
        typealias Root = MineModuleModel
        case userId, matrixData, referralNetworkData

        static let objectRelationalMapping = TableBinding(CodingKeys.self) {
            BindColumnConstraint(userId, isPrimary: true)
        }
    }
    
    class var current: MineModuleModel {
        if let mineModuleModel = MineModuleModel.getObject(where: WalletModuleModel.Properties.userId == UserInfo.userId) {
            return mineModuleModel
        } else {
            let mineModuleModel = MineModuleModel()
            mineModuleModel.userId = UserInfo.userId
            return mineModuleModel
        }
    }
    
}
